Skip to content

feat: add createX402PaymentHandler adapter for @acedatacloud/sdk#10

Merged
acedatacloud-dev merged 1 commit intomainfrom
feat/sdk-payment-handler
Apr 19, 2026
Merged

feat: add createX402PaymentHandler adapter for @acedatacloud/sdk#10
acedatacloud-dev merged 1 commit intomainfrom
feat/sdk-payment-handler

Conversation

@acedatacloud-dev
Copy link
Copy Markdown
Member

What

Adds createX402PaymentHandler — a factory that returns a paymentHandler function compatible with the new hook in @acedatacloud/sdk (see AceDataCloud/SDK PR). The adapter is also exported from the new @acedatacloud/x402-client/sdk subpath.

Why

Previously this package reinvented its own fetch wrapper (createX402Client, post, get) to do x402 flows, parallel to the official SDK. That meant users had to choose between "SDK with Bearer token" or "X402Client without task polling / streaming / typed errors."

This change makes X402Client a small plugin for the SDK instead. The SDK keeps doing everything it already does for every AceDataCloud endpoint; X402Client only contributes the signing of the X-Payment header.

Usage

import { AceDataCloud } from '@acedatacloud/sdk';
import { createX402PaymentHandler } from '@acedatacloud/x402-client';

const client = new AceDataCloud({
  paymentHandler: createX402PaymentHandler({
    network: 'base',
    evmProvider: window.ethereum,
    evmAddress: '0x...',
  }),
});

await client.openai.chat.completions.create({ ... });

The existing low-level createX402Client is preserved for e2e scripts and quick experiments; the README now recommends the SDK path for production.

Changes

  • new src/sdkAdapter.ts with createX402PaymentHandler
  • re-exported from src/index.ts
  • new ./sdk subpath export in package.json
  • README restructured to lead with the SDK integration; low-level client and Python direction documented below
  • npm run build passes

Companion PR in SDK: AceDataCloud/SDK#16 (opened just before this).

@acedatacloud-dev acedatacloud-dev merged commit 97c368d into main Apr 19, 2026
1 check passed
@acedatacloud-dev acedatacloud-dev deleted the feat/sdk-payment-handler branch April 19, 2026 16:16
Germey pushed a commit that referenced this pull request Apr 19, 2026
Follow-up to #10. With createX402PaymentHandler now wired into the
@acedatacloud/sdk transport, the standalone createX402Client +
post/get wrapper in src/client.ts is redundant — everyone should go
through the SDK, and the few places that need to bypass the SDK
already import the low-level signSolanaPayment / signEVMPayment
primitives directly.

Changes:
- delete src/client.ts (createX402Client, post, get, request)
- drop X402ClientOptions + X402Response from src/types.ts
- prune the top-level exports in src/index.ts
- rewrite README.md as a single coherent doc (the old README had
  been stacked, with duplicate sections referencing createX402Client)
- fix a stale console.log in scripts/test-e2e.ts

Public API after this change:
  createX402PaymentHandler, X402PaymentHandlerOptions
  signSolanaPayment, signEVMPayment
  PaymentRequirement, PaymentRequiredResponse, X402PaymentEnvelope
  SolanaWalletAdapter, EVMProvider, SolanaPayload, EVMPayload, EVMAuthorization

Build verified (npm run build → 0 errors).
acedatacloud-dev added a commit that referenced this pull request Apr 19, 2026
…11)

Follow-up to #10. With createX402PaymentHandler now wired into the
@acedatacloud/sdk transport, the standalone createX402Client +
post/get wrapper in src/client.ts is redundant — everyone should go
through the SDK, and the few places that need to bypass the SDK
already import the low-level signSolanaPayment / signEVMPayment
primitives directly.

Changes:
- delete src/client.ts (createX402Client, post, get, request)
- drop X402ClientOptions + X402Response from src/types.ts
- prune the top-level exports in src/index.ts
- rewrite README.md as a single coherent doc (the old README had
  been stacked, with duplicate sections referencing createX402Client)
- fix a stale console.log in scripts/test-e2e.ts

Public API after this change:
  createX402PaymentHandler, X402PaymentHandlerOptions
  signSolanaPayment, signEVMPayment
  PaymentRequirement, PaymentRequiredResponse, X402PaymentEnvelope
  SolanaWalletAdapter, EVMProvider, SolanaPayload, EVMPayload, EVMAuthorization

Build verified (npm run build → 0 errors).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant